HRESULT CreateMSMQQueue(LPSTR pszPathName, LPSTR pszLabel) {
char szFullPathName[256];
LPWSTR pwszPathName;
MQQUEUEPROPS QueueProps;
MQPROPVARIANT aVariant[10];
QUEUEPROPID aPropId[10];
HRESULT aStatus[10];
HRESULT hr;
DWORD PropIdCount = 0;
WCHAR szFormatNameBuffer[256];
DWORD dwFormatNameBufferLength;
LPWSTR wszLabel;
if(!pszPathName)return ERROR_INVALID_PARAMETER;
wsprintf(szFullPathName, ".\\PRIVATE$\\%s", pszPathName);
pwszPathName = Ansi2Unicode(szFullPathName, NULL);
wszLabel = Ansi2Unicode(pszLabel, NULL);
aPropId[PropIdCount] = PROPID_Q_PATHNAME;
aVariant[PropIdCount].vt = VT_LPWSTR;
aVariant[PropIdCount].pwszVal = pwszPathName;
PropIdCount++;
aPropId[PropIdCount] = PROPID_Q_LABEL;
aVariant[PropIdCount].vt = VT_LPWSTR;
aVariant[PropIdCount].pwszVal = wszLabel;
PropIdCount++;
QueueProps.cProp = PropIdCount;
QueueProps.aPropID = aPropId;
QueueProps.aPropVar = aVariant;
QueueProps.aStatus = aStatus;
dwFormatNameBufferLength = sizeof(szFormatNameBuffer)/sizeof(szFormatNameBuffer[0]);
hr = MQCreateQueue(NULL,
&QueueProps,
szFormatNameBuffer,
&dwFormatNameBufferLength);
GlobalFree(pwszPathName);
GlobalFree(wszLabel);
return hr;
} |